extends "../aijiang-1/aijiang-1.gd"

func _extInit():
	._extInit()
	lv = 2
	addSkill("每{cd}秒对随机队友造成[雷击*2]的伤害，并获得[伤害量*1%]的金币(一回合上限50金)", "痛击队友", "sk_banai2", 6)

var limit = 50
var p2 = 0.01
var gold = 0
var zhuanShu = false
func _onBattleEnd():
	._onBattleEnd()
	sys.main.player.plusGold(gold)
	gold = 0
	skFlag = true

func _onBattleStart():
	._onBattleStart()	
	for i in items:
		if i.id == "i_azurline_huangyouyou" and team == 1:
			zhuanShu = true
			break

func _castCdSkill(id):
	._castCdSkill(id)
	if id=="sk_banai":
		sk_banai()
	if id=="sk_banai2":
		sk_banai2()

func sk_banai():
	var cha = utils.getRndEnemy(self)
	if team == 2:
		azurHurtChara(cha, min(cha.att.maxHp*0.6, att.mgiAtk*2), sys.HurtType.WEAPON, sys.AtkType.EFF, "保护对手")
	else:
		healCha(cha, att.mgiAtk*2)
	if gold < limit and team == 1:
		gold += att.mgiAtk*2*p2

func sk_banai2():
	var cha
	if zhuanShu:
		cha = utils.getRndEnemy(self)
	else:
		cha = utils.getRndAlly(self)
	if team == 2:
		healCha(cha, att.mgiAtk*2)
	else:
		azurHurtChara(cha, att.mgiAtk*2, sys.HurtType.WEAPON, sys.AtkType.SKILL, "痛击队友", true)
	if gold < limit and team == 1:
		gold += att.mgiAtk*2*p2
var skFlag = true
func _upS():
	._upS()
	if skFlag and gold >= limit and lv == 4:
		skFlag = false
		for i in getAllChas(1):
			if i.hasBuff("b_xuanYun") == null:
				i.addBuff(buff.b_xuanYun.new(4))
				if upgraded == 1:
					buff.addLouShui(i, self, 5)
				if upgraded == 2:
					castBuff(i, buff.b_shuangDong.new(10))
					castBuff(i, buff.b_shaoShi.new(10))
	
